<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试 </title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script>
</head>
<body>
<div id="content"></div>
<script type="text/jsx">
    var data = [
        {id: 1, author: "Pete Hunt", text: "This is one comment"},
        {id: 2, author: "Jordan Walke", text: "This is *another* comment"}
    ];
    var Comment = React.createClass({
        rawMarkup: function() {
            var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
            return { __html: rawMarkup };
        },

        render: function() {
            return (
                    <div className="comment">
                        <h2 className="commentAuthor">
                            {this.props.author}
                        </h2>
                        <span dangerouslySetInnerHTML={this.rawMarkup()} />
                    </div>
            );
        }
    });
    var CommentList = React.createClass({
        render: function() {
            var commentNodes = this.props.data.map(function(comment) {
                return (
                        <Comment author={comment.author} key={comment.id}>
                            {comment.text}
                        </Comment>
                );
            });
            return (
                    <div className="commentList">
                        {commentNodes}
                    </div>
            );
        }
    });

    var CommentForm = React.createClass({
        render: function() {
            return (
                    <div className="commentForm">
                        Hello, world! I am a CommentForm.
                    </div>
            );
        }
    });
    var CommentBox = React.createClass({
        render: function() {
            return (
                    <div className="commentBox">
                        <h1>Comments</h1>
                        <CommentList data={this.props.data} />
                        <CommentForm />
                    </div>
            );
        }
    });
    ReactDOM.render(
            <CommentBox data={data} />,
            document.getElementById('content')
    );
</script>
</body>
</html>